import mongoose from 'mongoose'
import utils from '../utils'
const Schema = mongoose.Schema

const RequestFromIP = new Schema({
  api: String,
  ip: String,
  appid: String,
  createTime: {
    type: String,
    default: utils.currentTimeStamp()
  }
})

RequestFromIP.set('collection', 'RequestFromIP')

// hidden some field
RequestFromIP.options.toJSON = {
  virtuals: true,
  versionKey: false,
  transform (doc, ret) {
    ret.id = ret._id
    delete ret._id
  }
}
mongoose.model('RequestFromIP', RequestFromIP)
